// ------------------ useLog.ts ------------------
import { useMemo } from 'react';
import { LogCategories, LogGroups, LogGroupPrefixes } from '../component/EnhancedLogger/logConfig';
import { LogCategory } from '../utils/log/logCategory';
import { LogCategoryGroup } from '../utils/log/logCategoryGroup';

export function useLog() {
  const logCategory = useMemo(() => {
    const log = new LogCategory(Object.values(LogCategories));

    const categoryGroup = new LogCategoryGroup();
    log.bindCategoryGroup(categoryGroup);

    categoryGroup.registerGroups(log, {
      [LogGroups.UI_FLOW]: {
        categories: [LogCategories.UI, LogCategories.CLICK, LogCategories.INPUT],
        prefix: LogGroupPrefixes.UI_FLOW
      },
      [LogGroups.DATA_FLOW]: {
        categories: [LogCategories.DATA, LogCategories.API, LogCategories.EFFECT],
        prefix: LogGroupPrefixes.DATA_FLOW
      },
      [LogGroups.LIFECYCLE]: {
        categories: [LogCategories.MOUNT, LogCategories.UPDATE, LogCategories.UNMOUNT],
        prefix: LogGroupPrefixes.LIFECYCLE
      }
    });

    return { logCategory: log, categoryGroup };
  }, []);

  return logCategory;
}
